home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / mordor_2.000 / mordor_2 / src / special1.c < prev    next >
C/C++ Source or Header  |  1994-06-25  |  4KB  |  174 lines

  1. /*
  2.  * SPECIAL1.C:
  3.  *
  4.  *    User routines dealing with special routines.
  5.  *
  6.  *    Copyright (C) 1992, 1993 Brett J. Vickers
  7.  *
  8.  */
  9.  
  10. #include "mstruct.h"
  11. #include "mextern.h"
  12.  
  13. int    combo_box();
  14.  
  15. /************************************************************************/
  16. /*                special_obj                */
  17. /************************************************************************/
  18.  
  19. #define SP_INVENTORY 0
  20. #define SP_EQUIPMENT 1
  21. #define SP_ROOM      2
  22.  
  23. int special_obj(ply_ptr, cmnd, special)
  24. creature     *ply_ptr;
  25. cmd        *cmnd;
  26. int        special;
  27. {
  28.     object    *obj_ptr;
  29.     room    *rom_ptr;
  30.     int    fd, n, where;
  31.     char    str[80], str2[160], match=0, i;
  32.  
  33.     fd = ply_ptr->fd;
  34.     rom_ptr = ply_ptr->parent_rom;
  35.  
  36.     obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj,
  37.            cmnd->str[1], cmnd->val[1]);
  38.     where = SP_INVENTORY;
  39.  
  40.     if(!obj_ptr || !cmnd->val[1]) {
  41.         for(n=0; n<MAXWEAR; n++) {
  42.             if(!ply_ptr->ready[n]) continue;
  43.             if(EQUAL(ply_ptr->ready[n], cmnd->str[1]))
  44.                 match++;
  45.             else continue;
  46.             if(match == cmnd->val[1] || !cmnd->val[1]) {
  47.                 obj_ptr = ply_ptr->ready[n];
  48.                 where = SP_EQUIPMENT;
  49.                 break;
  50.             }
  51.         }
  52.     }
  53.  
  54.     if(!obj_ptr) {
  55.         obj_ptr = find_obj(ply_ptr, rom_ptr->first_obj,
  56.                    cmnd->str[1], cmnd->val[1]);
  57.         where = SP_ROOM;
  58.     }
  59.  
  60.     if(!obj_ptr) {
  61.         print(fd, "You don't see that.\n");
  62.         return(-1);
  63.     }
  64.  
  65.     if(obj_ptr->special != special)
  66.         return(-2);
  67.  
  68.     switch(obj_ptr->special) {
  69.     case SP_MAPSC:
  70.         strcpy(str, obj_ptr->name);
  71.         for(i=0; i<strlen(str); i++)
  72.             if(str[i] == ' ') str[i] = '_';
  73.         sprintf(str2, "%s/%s", OBJPATH, str);
  74.         view_file(fd, 1, str2);
  75.         return(DOPROMPT);
  76.     case SP_COMBO:
  77.         return(combo_box(ply_ptr, obj_ptr));
  78.     default:
  79.         print(fd, "Nothing.\n");
  80.     }
  81.  
  82.     return(0);
  83. }
  84.  
  85. /************************************************************************/
  86. /*                special_cmd                */
  87. /************************************************************************/
  88.  
  89. int special_cmd(ply_ptr, special, cmnd)
  90. creature    *ply_ptr;
  91. int        special;
  92. cmd        *cmnd;
  93. {
  94.     int n, fd;
  95.  
  96.     fd = ply_ptr->fd;
  97.  
  98.     switch(special) {
  99.     case SP_MAPSC:
  100.     case SP_COMBO:
  101.         if(cmnd->num < 2) {
  102.             print(fd, "Do that to what?\n");
  103.             return(0);
  104.         }
  105.         n = special_obj(ply_ptr, cmnd, special);
  106.         if(n == -1) return(0);
  107.         if(n == -2) {
  108.             print(fd, "I'd like to see you try.\n");
  109.             return(0);
  110.         }
  111.         else return(n);
  112.     default:
  113.         print(ply_ptr->fd, "Nothing happens.\n");
  114.         return(0);
  115.     }
  116. }
  117.  
  118. /************************************************************************/
  119. /*                combo_box                */
  120. /************************************************************************/
  121.  
  122. int combo_box(ply_ptr, obj_ptr)
  123. creature    *ply_ptr;
  124. object        *obj_ptr;
  125. {
  126.     xtag    *xp;
  127.     room    *rom_ptr;
  128.     char    str[80];
  129.     int    fd, dmg, i;
  130.  
  131.     fd = ply_ptr->fd;
  132.     rom_ptr = ply_ptr->parent_rom;
  133.  
  134.     str[0] = obj_ptr->sdice+'0'; str[1] = 0;
  135.  
  136.     if(obj_ptr->ndice == 1 || strlen(Ply[fd].extr->tempstr[3]) > 70)
  137.         strcpy(Ply[fd].extr->tempstr[3], str);
  138.     else
  139.         strcat(Ply[fd].extr->tempstr[3], str);
  140.  
  141.     print(fd, "Click.\n");
  142.     broadcast_rom(fd, ply_ptr->rom_num, "%M presses %i.", ply_ptr, obj_ptr);
  143.  
  144.     if(strlen(Ply[fd].extr->tempstr[3]) >= strlen(obj_ptr->use_output)) {
  145.         if(strcmp(Ply[fd].extr->tempstr[3], obj_ptr->use_output)) {
  146.             dmg = mrand(20,40);
  147.             ply_ptr->hpcur -= dmg;
  148.             print(fd, "You were zapped for %d damage!\n", dmg);
  149.             broadcast_rom(fd, ply_ptr->rom_num,
  150.                 "%M was zapped by %i!", ply_ptr, obj_ptr);
  151.             Ply[fd].extr->tempstr[3][0] = 0;
  152.  
  153.             if(ply_ptr->hpcur < 1) {
  154.                 print(fd, "You died.\n");
  155.                 die(ply_ptr, ply_ptr);
  156.             }
  157.         }
  158.  
  159.         else {
  160.             for(i=1, xp=rom_ptr->first_ext;
  161.                 xp && i < obj_ptr->pdice;
  162.                 i++, xp = xp->next_tag) ;
  163.             if(!xp) return(0);
  164.             print(fd, "You opened the %s!\n", xp->ext->name);
  165.             broadcast_rom(fd, ply_ptr->rom_num,
  166.                 "%M opened the %s!", ply_ptr, xp->ext->name);
  167.             F_CLR(xp->ext, XLOCKD);
  168.             F_CLR(xp->ext, XCLOSD);
  169.             xp->ext->ltime.ltime = time(0);
  170.         }
  171.     }
  172.     return(0);
  173. }
  174.